home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C++ für Kids
/
C++ for kids.iso
/
Buch
/
Kohle2.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1998-12-14
|
1KB
|
52 lines
//---------------------------------------------------------------------------
#include <vcl\vcl.h>
#pragma hdrstop
#include "Kohle2.h"
//---------------------------------------------------------------------------
#pragma resource "*.dfm"
TForm1 *Form1;
float Kapital, Zinsen, Prozent; int Nr, Laufzeit;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Nr++;
if (Nr == 1)
{
Kapital = StrToFloat (Edit1->Text);
Label1->Caption = "Wie hoch soll der Zinssatz sein?";
Edit1->Text = "";
Edit1->SetFocus ();
}
if (Nr == 2)
{
Prozent = StrToFloat (Edit1->Text);
Laufzeit = 0;
do
{
Zinsen = Kapital * Prozent / 100;
Kapital = Kapital + Zinsen;
if (Kapital < 1000000) Laufzeit++;
}
while (Kapital < 1000000);
if (Laufzeit > 0)
Label1->Caption = "Dein Geld mu▀ "
+ IntToStr (Laufzeit) + " Jahre auf der Bank braten";
else
Label1->Caption = "Willkommen im Club der MillionΣre!";
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Nr = 0;
}
//---------------------------------------------------------------------------